﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ERP_RORZE_TOOL.Common;

namespace ERP_RORZE_PRODUCT.Product.BusOder
{
    public partial class Frm_ImportReport : Form
    {
        private string table = "Table: BusOrder\r\n";
        private string time = "Time import: " + DateTime.Now.ToString() + "\r\n";
        private string okStr = "Import successfully: ";
        private string errStr = "Import error: ";
        private string dupStr = "Import duplicate: ";
        public Frm_ImportReport(int ok, List<Utilities.ListItem> dup, List<Utilities.ListItem> err, string table=null, string keys=null)
        {
            InitializeComponent();
            
            if (table!=null)
            {
                this.table = "Table: "+table+"\r\n";
            }
            okStr += ok.ToString() + " records \r\n";
            okStr += "\r\n";

            //add error
            errStr += err.Count + " records \r\n";
            errStr += "   Line : " + keys + " : Error\r\n";
            foreach (Utilities.ListItem item in err)
            {
                errStr += "   " + item.ID + " : " + item.Value + " : " + item.Note + "\r\n";
            }
            errStr += "\r\n";

            //add dup
            dupStr += dup.Count + " records \r\n";
            dupStr += "   Line : "+keys+" : Error\r\n";
            foreach (Utilities.ListItem item in dup)
            {
                dupStr += "   " + item.ID + " : " + item.Value + " : " + item.Note + "\r\n";
            }
            dupStr += "\r\n";

            memoEdit1.Text = this.table + time + "Total rows: " + (ok + dup.Count + err.Count).ToString() + "\r\n\r\n" + okStr + dupStr + errStr;
            memoEdit1.Visible = true;
        }
    }
}
